//
//  LPDCDetailModel.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 17/5/6.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPDCDetailModel.h"

@implementation LPDCDetailModel

- (void)setTITLE:(NSString *)TITLE{
    _TITLE = TITLE;
    CGFloat width;
    /**  通过不同类型去不同的宽度，计算高度  */
    if ([self.DISPLAY isEqualToString:@"1"]) {
        width = [UIScreen zj_screenWith] * 0.6 - 40 * [UIScreen zj_screenWScale];
      
    }else if ([self.DISPLAY isEqualToString:@"2"]){
        width = [UIScreen zj_screenWith] - 30 * [UIScreen zj_screenWScale];
    }else if ([self.DISPLAY isEqualToString:@"3"]){
         width = [UIScreen zj_screenWith] - 30 * [UIScreen zj_screenWScale];
    }else{
        width = [UIScreen zj_screenWith] - 30 * [UIScreen zj_screenWScale];
    }
    
    self.height = [CalculateLabelHeight calculateLabeHeightWithString:TITLE font:15 * [UIScreen zj_textFontScale] width:width space:4 * [UIScreen zj_screenHScale]];
    
}

- (void)setABSTRACT:(NSString *)ABSTRACT{
    _ABSTRACT = ABSTRACT;
     self.IKnowedgeContentHeight = [CalculateLabelHeight calculateLabeHeightWithString:ABSTRACT font:14 * [UIScreen zj_textFontScale] width:[UIScreen zj_screenWith] * 0.6 - 40 * [UIScreen zj_screenWScale] space:3 * [UIScreen zj_screenHScale]];
}

- (CGFloat )cellHeight{
    if ([self.DISPLAY isEqualToString:@"3"]) {
        
        return 210 * [UIScreen zj_screenHScale] + self.height;
    }else if ([self.DISPLAY isEqualToString:@"1"]){
        return 115 * [UIScreen zj_screenHScale];
    }else if ([self.DISPLAY isEqualToString:@"2"]){
        
        return 60 * [UIScreen zj_screenHScale] + self.height + 70 * [UIScreen zj_screenHScale] ;
        
    }else{
       
        return 60 * [UIScreen zj_screenHScale] + self.height;
       
        
    }
}


-(void)calculateTitleStringSize{
    NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setLineSpacing:ItemPX * 14];
    self.titleSize = [self.TITLE boundingRectWithSize:CGSizeMake([UIScreen zj_screenWith] - ItemPX * 451, ItemPX * 151) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : LYPBOLDFONT(16) , NSParagraphStyleAttributeName : paragraphStyle} context:nil].size;
    paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping;
    NSMutableAttributedString * tempAttributeString = [[NSMutableAttributedString alloc]initWithString:self.TITLE];
    [tempAttributeString addAttribute:NSFontAttributeName value:LYPBOLDFONT(16) range:NSMakeRange(0, self.TITLE.length)];
    [tempAttributeString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, self.TITLE.length)];
    self.titleAttributedString = tempAttributeString;
}




@end
